package com.etone.smartAudit.controller;

import com.etone.smartAudit.enums.TaskType;
import com.etone.smartAudit.service.OfficeService;
import com.etone.smartAudit.vo.PagerVO;
import com.etone.smartAudit.vo.source.SourceSimpleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 蒋学伟
 * @create: 2020-06-17 10:00:18
 * @Description SourceController
 */
@RestController
@AllArgsConstructor
@Api(tags = "资源信息", value = "SourceController")
public class SourceController {

    private OfficeService officeService;

    @ApiOperation(value = "超级本信息")
    @GetMapping("/sources/super/simple")
    public SourceSimpleVO findSuperSource() {
        return officeService.findOneByType(TaskType.SUPER_WORK);
    }

    @ApiOperation(value = "工作站信息")
    @GetMapping("/sources/work/simple")
    public SourceSimpleVO findWorkSource() {
        return officeService.findOneByType(TaskType.WORK_STATION);
    }

    @ApiOperation(value = "临时资源信息")
    @GetMapping("/sources/temporary/simple")
    public PagerVO<SourceSimpleVO> findTemporarySource(
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return officeService.findTemporarySource(page, pageSize);
    }
}
